<!--
 * @Description: 数据字典表单
 * @Autor: Zhu_liangyu
 * @Date: 2020-05-09 10:52:56
--> 
<template>
  <basic-form
    ref="dictionaryForm"
    v-model="dictionaryForm"
    :rules="dictionaryRule"
    primary-key="dictionaryId"
    form-type="dialog"
    :query-api="dictionary_queryByIdApi"
    :insert-api="dictionary_insertApi"
    :update-api="dictionary_updateApi"
  >
    <a-form-model-item label="类型标识" prop="codeId" ref="codeId" :hasFeedback="true">
      <a-input v-model="dictionaryForm.codeId" placeholder="请输入字典标识" />
    </a-form-model-item>
    <a-form-model-item label="字典名称" prop="codeName">
      <a-input v-model="dictionaryForm.codeName" placeholder="请输入字典名称" :hasFeedback="true" />
    </a-form-model-item>
    <a-form-model-item label="排序" prop="sortNo">
      <a-input v-model.number="dictionaryForm.sortNo" placeholder="请输入排序" :hasFeedback="true" />
    </a-form-model-item>
  </basic-form>
</template>
<script>
import {
  dictionary_queryByIdApi,
  dictionary_insertApi,
  dictionary_updateApi
} from "@/api/cms/dictionary";
import { dictionaryRule } from "@/profile/cms/dictionary";
export default {
  props: {
    codeItemId: {
      //数据字典类别标识
      type: String
    },
    dictionaryId: {
      type: String
    }
  },
  data() {
    return {
      dictionary_queryByIdApi,
      dictionary_insertApi,
      dictionary_updateApi,
      dictionaryForm: {
        dictionaryId: this.dictionaryId,
        codeItemId: undefined
      },
      dictionaryRule
    };
  },
  created() {
    //新增时操作
    if (!this.dictionaryId) this.dictionaryForm.codeItemId = this.codeItemId;
  }
};
</script>